<?php
//此文档为判断比赛合法页
require_once("./include/bm_config.php");
require_once("./include/funcs.php");
?>
<?php
$is_admin = isset($_SESSION['administrator']) || isset($_SESSION[$BM_ADMIN]);
$user_id = $_SESSION['user_id'];

//读教练信息
$sql="SELECT * FROM `cr_user` WHERE `user_id`='$user_id' ";
$result=mysql_query($sql);
$row=mysql_fetch_object($result);	
$user_active0 = $row->user_active0;
$user_active1 = $row->user_active1;
mysql_free_result($result);
if(($user_active0 == 'N' && $user_active1 == 'N' || !isset($_SESSION['user_id'])) &&!isset($_SESSION['administrator']) &&  !isset($_SESSION[$BM_ADMIN]))
{
?>
		<div class="content bolr">
		<style type="text/css">
		<!--
		.STYLE1 {color: #FF3300}
		-->
		</style>
		<h2 class="h2">用户未登录或未激活，无法进行比赛注册。</h2>
      	<div class="middle">
          <table border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="30">&nbsp;</td>
              <td height="30" colspan="2" align="left"><span class="STYLE1">用户注册：点击页眉“【<strong><a href="<?php echo $BM_HOME."/registerpage.php";?>">注册教练帐号</a></strong>】”按要求认真填写信息后提交。</span></td>
            </tr>
            <tr>
              <td height="30">&nbsp;</td>
              <td height="30" colspan="2" align="left"><span class="STYLE1">用户激活：登录后点击页眉“【<strong><a href="<?php echo $BM_HOME."/userinfo.php";?>">查看帐号信息</a></strong>】”，上传有相关单位公章的身份证明文件的清晰扫描或拍照附件（打包为RAR或ZIP格式上传），管理员会定期检查公文并激活用户。</span></td>
            </tr>
          </table>
         </div>
		<div style="height:150px;"></div>
		</div>
<?php 
		
		require_once("./bm_footer.php");
		exit(0);
}


$sql="SELECT * FROM `cr_contest` WHERE `contest_id`='$cid' ";
$result=mysql_query($sql);
$rows_cnt=mysql_num_rows($result);
$row=mysql_fetch_object($result);	
mysql_free_result($result);
if ($rows_cnt==0)
{
?>
		<script language='javascript'>
		alert('没有这样一个比赛!');
		history.go(-1);
		</script>
		<div class="content bolr">
    <h2 class="h2">没有这样一个比赛!</h2>
		<div style="height:150px;"></div>
		</div>
<?php 

		
		exit(0);
}
$now=time();
$contest_id = $row->contest_id;							//比赛ID（1000起始的数字）
$contest_title = $row->contest_title;					//比赛标题
$contest_0_start = strtotime($row->contest_0_start);	//算法赛开始注册时间
$contest_0_end = strtotime($row->contest_0_end);		//算法赛结束注册时间
$contest_0_description = $row->contest_0_description; 	//算法赛辅助描述
$contest_0_active = $row->contest_0_active;				//是否有算法赛（允许只建立项目赛，当然一般这个选项是'Y'）
$contest_1_start = strtotime($row->contest_1_start);	//项目赛开始注册时间
$contest_1_end = strtotime($row->contest_1_end);		//项目赛结束注册时间
$contest_1_description = $row->contest_1_description;	//项目赛辅助描述
$contest_1_active = $row->contest_1_active;				//是否有项目赛
$contest_active = $row->contest_active;					//比赛是否是隐藏状态

$view_start_time0 = $row->contest_0_start;
$view_end_time0 = $row->contest_0_end;
$view_start_time1 = $row->contest_1_start;
$view_end_time1 = $row->contest_1_end;

$contest_ok = true;
if ($row->contest_active=='N' || !isset($_SESSION['user_id'])) $contest_ok=false;
if (isset($_SESSION['administrator']) || isset($_SESSION[$BM_ADMIN])) $contest_ok=true;
if (!$contest_ok)
{
?>
	<script language='javascript'>
	alert('没有访问权限!');
	history.go(-1);
	</script>;
	<div class="content bolr">
    <h2 class="h2">没有访问权限!</h2>
	<div style="height:150px;"></div>
	</div>
<?php
	
	exit(0);
}
?>
 